<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Product extends MY_Controller {
    
	public function __construct(){
		parent::__construct();
	}
	
	function index(){
	    $this->_data['tm_product'] = ' ctm ';
		$this->load->view('product/index',$this->_data);
	}

	function cat(){
		if(empty($this->p['id'])) die;
		$id = intval($this->p['id']);

		$list_cat = $this->cm->get_all($this->tbl->cat,array('mid'=>'11'),'',0,'a');
		$this->_data['list_cat'] = $list_cat;

		$arr_id = getCatSubId($list_cat,$id);

	    $this->load->library('pagination');
	    $limit_num = !empty($this->p['per_page']) ? intval($this->p['per_page']) : 0;


	    $conf_page = config_item('pagefollow');

		$list_product = $this->cm->get_page('custom_product','*',
			array('cid'=>$arr_id),
			array('imgs|m'=>'images:id,path','img|s'=>'images:id,path'),
			$limit_num,$conf_page['per_page'],'a');			

	    //分页导航
	    $this->pagination->initialize($conf_page); 
    	$this->pagination->base_url = $this->page_url();;
	    $this->pagination->total_rows = $this->cm->count;
	    $this->_data['pagenav'] = $this->pagination->create_links();

		$this->_data['list_product'] = $list_product;

	    $this->_data['tm_product'] = ' ctm ';

		$this->load->view('product/cat',$this->_data);
	}
	
}
